<%--
 * list.jsp
 *
 * Copyright (C) 2013 Universidad de Sevilla
 * 
 * The use of this project is hereby constrained to the conditions of the 
 * TDG Licence, a copy of which you may download from 
 * http://www.tdg-seville.info/License.html
 --%>

<%@page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@taglib prefix="jstl" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="security"
	uri="http://www.springframework.org/security/tags"%>
<%@taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@taglib prefix="acme" tagdir="/WEB-INF/tags"%>


<display:table pagesize="5" class="displaytag" keepStatus="true"
	name="events" requestURI="${requestURI}" id="row">


	<security:authorize access="hasRole('ADMINISTRATOR')">
		<display:column>
			<a href="event/administrator/edit.do?eventId=${row.id}"><spring:message
					code="event.view" /></a>
		</display:column>

	</security:authorize>

	<security:authorize access="hasRole('PARTICIPANT')">
		<display:column>
			<a href="event/participant/edit.do?eventId=${row.id}"><spring:message
					code="event.view" /></a>
		</display:column>

	</security:authorize>

	<security:authorize access="isAnonymous()">
		<display:column>
			<a href="event/edit.do?eventId=${row.id}"><spring:message
					code="event.view" /></a>

		</display:column>
	</security:authorize>


			<spring:message code="event.title" var="titleHeader" />
			<display:column property="title" title="${titleHeader}"
				sortable="false" />

			<spring:message code="event.fee" var="feeHeader" />
			<display:column property="fee" title="${feeHeader}" sortable="false" />

			<spring:message code="event.creationMoment"
				var="creationMomentHeader" />
			<display:column property="creationMoment"
				title="${creationMomentHeader}" sortable="false"
				format="{0,date,dd/MM/yyyy HH:mm}" />

			<spring:message code="event.startMoment" var="startMomentHeader" />
			<display:column property="startMoment" title="${startMomentHeader}"
				sortable="false" format="{0,date,dd/MM/yyyy HH:mm}" />


			<spring:message code="event.finishMoment" var="finishMomentHeader" />
			<display:column property="finishMoment" title="${finishMomentHeader}"
				sortable="false" format="{0,date,dd/MM/yyyy HH:mm}" />


			<spring:message code="event.description" var="descriptionHeader" />
			<display:column property="description" title="${descriptionHeader}"
				sortable="false" />

			<spring:message code="event.rating" var="ratingHeader" />
			<display:column property="rating" title="${ratingHeader}"
				sortable="false" />
			<spring:message code="event.numberOfParticipants"
				var="numberOfParticipants" />
			<display:column value="${row.registrations.size()}"
				title="${numberOfParticipants}" sortable="false" />
		
</display:table>

<!-- Action links -->

<security:authorize access="hasRole('ADMINISTRATOR')">

	<a href="event/administrator/create.do?eventId=${row.id}"><spring:message
			code="event.create" /></a>

</security:authorize>

<security:authorize access="hasRole('ADMINISTRATOR')">
		<acme:cancel code="challenge.goBack" url="${backURI}" />
	</security:authorize>
	
	<security:authorize access="hasRole('PARTICIPANT')">
		<acme:cancel code="challenge.goBack" url="${backURI}" />
	</security:authorize>
	
	<security:authorize access="isAnonymous()">
		<acme:cancel code="challenge.goBack" url="${backURI}" />
	</security:authorize>

